package com.runjian.rundo.iot.agent.common.message;

import java.util.ArrayList;
import java.util.List;

import com.runjian.rundo.iot.agent.common.enums.DeviceMessageType;
import lombok.Getter;

/**
 * 设备属性上报消息 默认实现
 *
 * @author LiGang
 */
@Getter
public class DefaultDeviceMessage implements DevicePropertiesMessage {

    private String deviceId;

    private String externalId;

    private List<DecodedMessage> decodedMessages = new ArrayList<>();

    private DeviceMessageType deviceMessageType;

    public DefaultDeviceMessage() {
        this("", "");
    }

    public DefaultDeviceMessage(String deviceId, String externalId) {
        this(externalId, externalId, new ArrayList<>());
        this.deviceMessageType = DeviceMessageType.PROPERTIES;
    }

    public DefaultDeviceMessage(String deviceId, String externalId, DeviceMessageType deviceMessageType) {
        this.deviceId = deviceId;
        this.externalId = externalId;
        this.deviceMessageType = deviceMessageType;
    }

    public DefaultDeviceMessage(String deviceId, String externalId, List<DecodedMessage> decodedMessageList) {
        this.deviceId = deviceId;
        this.externalId = externalId;
        this.decodedMessages = decodedMessageList;
    }

    @Override
    public void addDecodedMessages(DecodedMessage decodedMessage) {
        this.decodedMessages.add(decodedMessage);
    }

    @Override
    public DeviceMessageType getType() {
        return deviceMessageType;
    }
}
